<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>
        计算属性
    </title>
    <script type="text/javascript" src="../js/vue.js"></script>
</head>

<body>

    <div id="root">
        <h1>4 计算属性实现</h1>
        姓：<input type="text" v-model="firstName">
        <br> </br>
        名：<input type="text" v-model="lastName">
        <br> </br>
        <!-- 姓名：<span>{{firstName.slice(0,3)}}-{{lastName}}</span> -->
        姓名：<span> 什么这是什么{{fullname}} </span><br> </br>


    </div>
</body>

<script type="text/javascript">
    Vue.config.productionTip = false
    let vm = new Vue({
        el: '#root',
        data() {
            return {
                firstName: '张',
                lastName: '三',
                fullname: "张三"
            }
        },

        watch: {
            firstName: {
                handler(newValue, oldValue) {
                    console.log("输出")
                    console.log(newValue)
                    this.fullname = newValue + this.lastName
                }
            },
            lastName(newValue, oldValue) {
                this.fullname = this.firstName + newValue
            }
        }
    })
</script>

</html>